package com.javalab.recorder.state;

import com.javalab.recorder.audio.AudioCache;
import com.javalab.recorder.audio.AudioCaptureThread;

public class RecordingState extends AbstractRecorderState {

	private static RecordingState state;

	private RecordingState() {

	}

	public static RecordingState getInstance() {
		synchronized (RecordingState.class) {
			if (state == null) {
				state = new RecordingState();
			}
			return state;
		}
	}

	private AudioCaptureThread audioCaptureThread;

	@Override
	public boolean isRecordButtonEnabled() {
		return false;
	}

	@Override
	public boolean isPlaybackButtonEnabled() {
		return false;
	}

	@Override
	public boolean isStopButtonEnabled() {
		return true;
	}

	@Override
	public void doRecording() {

	}

	@Override
	public void doPlaying() {

	}

	@Override
	public void doStopping() {
		byte[] data = audioCaptureThread.stopCapturing();
		AudioCache.getInstance().put("CapturedAudioData", data);
		mainFrame.setRecorderState(StoppedState.getInstance());
	}

	public AudioCaptureThread getAudioCaptureThread() {
		return audioCaptureThread;
	}

	public void setAudioCaptureThread(AudioCaptureThread audioCaptureThread) {
		this.audioCaptureThread = audioCaptureThread;
	}

}
